<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Details du fournisseur</title>


<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form validation ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.validate.js');?>" ></script>
<!---------------------for form mask input ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.mask.min.js');?>" ></script>


</head>
<body>
<?php
include_once('header.php');

$r1=$liste_fourn['rec1'];
$r2=$liste_activite['rec2'];



$liste_des_fournisseurs = array();
foreach ($r1 as $lf){
	array_push($liste_des_fournisseurs, $lf->nom);
}

$liste_des_activites = array();
foreach ($r2 as $lda){
	array_push($liste_des_activites, $lda->titre);
	
}

?>

<!--<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>-->


<form class="pure-form pure-form-stacked">
    <fieldset>
        <legend>تفاصيل المورد</legend>

        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="nom">الاسم </label>
                <input id="nom" type="text">
            </div>

            <div class="pure-u-1 pure-u-md-1-3 ">
                <label for="phone">الهاتف </label>
                <input  class="ltr" id="phone" type="text">
            </div>

            <div class="pure-u-1 pure-u-md-1-3 ">
                <label for="mobile"> النقال </label>
				<input class="ltr" id="mobile" type="text" >
                <!--<input id="email" type="email" >-->
            </div>

            <div class="pure-u-1 pure-u-md-1-3 ">
                <label for="fax">الفاكس </label>
                <input class="ltr" id="fax" type="text" >
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3">
                <label for="address">العنوان  </label>
                <input id="address" type="text">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3">
                <label for="rc"> السجل التجاري/autre  </label>
                <input  class="ltr" id="rc" type="text"  placeholder="00/00-00000(0000)A00">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3">
                <label for="rib"> تفاصيل البنك  </label>
                <input   class="ltr" style="width: 225px;" id="rib" type="text">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3">
                <label for="type_activit">  طبيعة النشاط</label>
                <input id="type_activit" type="text">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3">
                <label for="email"> البريد الإلكتروني  </label>
                <input  class="ltr" id="email" type="email">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3">
                <label for="contact">  نقطة الإتصال  </label>
                <input id="contact" type="text">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3">
                <label for="notes">  ملاحظات  </label>
                <textarea id='notes' rows="4" cols="50">  </textarea>  
            </div>
			

            <!--<div class="pure-u-1 pure-u-md-1-3">
                <label for="state">State</label>
                <select id="state" class="pure-input-1-2">
                    <option>AL</option>
                    <option>CA</option>
                    <option>IL</option>
                </select>
            </div>-->
			
        </div>

      

        <button type="submit" id="submit_btn" class="pure-button pure-button-primary">موافق</button>
    </fieldset>
</form>


</body>
<script>
$(function() {
	

var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
var liste_activites = <?php echo json_encode($liste_des_activites); ?>;

$( "#nom" ).autocomplete({source: liste_fourniss});
$( "#type_activit" ).autocomplete({source: liste_activites});






});

//---
$('#submit_btn').click(function() {
  if($('span.error').length > 0){
    alert('Errors!');
    return false;
  } else {
    $('#btn-submit').after('<span class="error">Form Accepted.</span>');
    return false;
  }
});


$('#rc').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    //var characterReg = /^([a-zA-Z0-9]{7,16})$/;
    var characterReg = /^([0-9]{2}\/[0-9]{2}-[0-9]{5,9}[a-zA-Z][0-9]{2})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" style="color:red;" >format incorrect</span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});

//---
$('#rib').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\d{3}-\d{5}-\d{10}-\d{2})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" style="color:red;" >format incorrect</span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});

$('#phone').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\(\d{3}\)-\d{2}-\d{2}-\d{2})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" style="color:red;" >format incorrect</span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});

$('#mobile').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\(\d{4}\)-\d{2}-\d{2}-\d{2})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" style="color:red;" >format incorrect</span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});

$('#email').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\b[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b)$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" style="color:red;" >format incorrect</span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});



//---* maskage below 
$('#rc').mask('AA/AA-AAAAAOOOODAA', {'translation': {
                                        A: {pattern: /[0-9]/},
										O: {pattern: /[0-9]/, optional: true},
										D: {pattern: /[a-zA-Z]/}
                                      }
                                });

$('#rib').mask('000-00000-0000000000-00');
$('#phone').mask('(A00)-00-00-00',{'translation': { A: {pattern: /[0]/} } });
$('#mobile').mask('(AB00)-00-00-00',{'translation': { A: {pattern: /[0]/},B: {pattern: /[5,6,7]/} } }); // nedjma djeezy et mobilis 							
$('#fax').mask('(A00)-00-00-00',{'translation': { A: {pattern: /[0]/} } });



</script>
</html>